package server;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;

import javax.imageio.ImageIO;


public class TryImage implements Serializable
{
	String msg;
	BufferedImage image = new BufferedImage(301,301,BufferedImage.TYPE_INT_RGB);
	
	public TryImage(String msg , String filepath) throws IOException
	{
		this.msg = msg;
		String u = filepath;
		image = ImageIO.read(new File(u));
		int i=0;
	}
	
	public BufferedImage getBufferedImage()
	{
		return image;
	}
	
	private void writeObject(java.io.ObjectOutputStream out)throws IOException
	{
	    out.writeObject(msg);
	    ImageIO.write(image,"png",ImageIO.createImageOutputStream(out));
	}

	  private void readObject(java.io.ObjectInputStream in)throws IOException, ClassNotFoundException
	{
	    msg=(String)in.readObject();
	    image=ImageIO.read(ImageIO.createImageInputStream(in));
	}
	  
	public String getMsg() 
	{
		return msg;
	}

}